package org.dromara.business.modules.searchHistory.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import org.dromara.business.modules.searchHistory.domain.bo.BuSearchHistoryBo;
import org.dromara.business.modules.searchHistory.domain.vo.BuSearchHistoryVo;
import org.dromara.business.modules.searchHistory.domain.vo.SearchHistoryVo;
import org.dromara.business.modules.searchHistory.domain.vo.SearchVo;
import org.dromara.business.modules.searchHistory.service.IBuSearchHistoryService;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户搜索历史记录
 *
 * @author ckk
 * @date 2025-11-10
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/searchHistory")
public class BuSearchHistoryController extends BaseController {

    private final IBuSearchHistoryService buSearchHistoryService;

    /**
     * 搜索服务或需求
     */
    @SaIgnore
    @GetMapping("/search")
    public TableDataInfo<SearchVo> search(String keyword, PageQuery pageQuery) {
        return buSearchHistoryService.search(keyword, pageQuery);
    }

    /**
     * 查询用户搜索历史记录列表
     */
    @SaIgnore
    @GetMapping("/list")
    public TableDataInfo<BuSearchHistoryVo> list(BuSearchHistoryBo bo, PageQuery pageQuery) {
        return buSearchHistoryService.queryPageList(bo, pageQuery);
    }

    /**
     * 热门搜索
     */
    @SaIgnore
    @GetMapping("/hotSearch")
    public TableDataInfo<SearchHistoryVo> hotSearch(PageQuery pageQuery) {
        return buSearchHistoryService.hotSearch(pageQuery);
    }


}
